// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asSceneComponent.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the SceneComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __ASSCENECOMPONENT_H__
#define __ASSCENECOMPONENT_H__

// Include files
#include "../../../dependencies.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"
#include "../../core/asEntityComponent.h"

#include "../../../components/scene/SceneComponent.h"


//! Binds the SceneComponent class to AngelScript.
extern void bindSceneComponent(asIScriptEngine *engine);

//! Binds the base behaviours and methods of the SceneComponent to the given class in
//! AngelScript.
template<typename T>
void bindSceneComponentBase(asIScriptEngine *engine, const char *type)
{
    // Forward declaration.
    int r;
    std::string sType = type;

    // Bind inherited functions.
    bindEntityComponentBase<SceneComponent>(engine, type);

    // Set common behaviour.
    r = engine->RegisterObjectBehaviour("SceneComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(),
                                        asFUNCTION((asRefCast<SceneComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );
    r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("SceneComponent@ f()").c_str(),
                                        asFUNCTION((asRefCast<T,SceneComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );

    // Bind common class functions.
    r = engine->RegisterObjectMethod(type, "void addCollisionResponseAnimator(const vector3df &in, " \
                                     "const vector3df &in, const vector3df &in, f32)",
                                     asMETHOD(T, addCollisionResponseAnimator), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void addFlyCircleAnimator(const vector3df &in, f32, " \
                                     "f32, const vector3df &in)",
                                     asMETHOD(T, addFlyCircleAnimator), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void addFlyStraightAnimator(const vector3df &in, " \
                                     "const vector3df &in, u32, bool)",
                                     asMETHOD(T, addFlyStraightAnimator), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod(type, "void addToMetaSelector(Entity@)",
                                     asMETHODPR(T, addToMetaSelector, (Entity*), void), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void addToMetaSelector(SceneComponent@)",
                                     asMETHODPR(T, addToMetaSelector, (SceneComponent*), void), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod(type, "const vector3df& getAbsolutePosition()",
                                     asMETHOD(T, getAbsolutePosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "E_CULLING_TYPE  getAutomaticCulling()",
                                     asMETHOD(T, getAutomaticCulling), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "const aabbox3df& getBoundingBox()",
                                     asMETHODPR(T, getBoundingBox, (void) const, const aabbox3df&), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "u32 getMaterialCount()",
                                     asMETHOD(T, getMaterialCount), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "const matrix4& getRelativeTransformation()",
                                     asMETHOD(T, getRelativeTransformation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "const vector3df& getPosition()",
                                     asMETHOD(T, getPosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "const vector3df& getRotation()",
                                     asMETHOD(T, getRotation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "const vector3df& getScale()",
                                     asMETHOD(T, getScale), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod(type, "void removeAnimators()",
                                     asMETHOD(T, removeAnimators), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod(type, "void setAbsolutePosition(const vector3df &in)",
                                     asMETHOD(T, setAbsolutePosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setAutomaticCulling(E_CULLING_TYPE)",
                                     asMETHOD(T, setAutomaticCulling), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setCanAffectParent(bool)",
                                     asMETHOD(T, setCanAffectParent), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setDebugDataVisible(s32)",
                                     asMETHOD(T, setDebugDataVisible), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setMaterialFlag(E_MATERIAL_FLAG, bool)",
                                     asMETHOD(T, setMaterialFlag), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setMaterialTexture(u32, const string &in)",
                                     asMETHODPR(T, setMaterialTexture, (u32 layer, const std::string &fileName), void),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setMaterialType(E_MATERIAL_TYPE)",
                                     asMETHOD(T, setMaterialType), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setPosition(const vector3df &in)",
                                     asMETHOD(T, setPosition), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setRotation(const vector3df &in)",
                                     asMETHOD(T, setRotation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setScale(const vector3df &in)",
                                     asMETHOD(T, setScale), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod(type, "void setVisible(bool)",
                                     asMETHOD(T, setVisible), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

#endif
